define(function(require, exports){
	var pubjs		= require('pubjs');
	var baseGrid	=require('@base/grid').baseNoDate;
	var $			= require('jquery');

	var Base = baseGrid.extend({
		init: function(config){
			config = pubjs.conf(config, {
				"cols":[
					{name:'_id', width:50, align:'center',sort:false},
					{name:"UserName",text:LANG("公司名称"),sort:false,type:"index",width:220,render:'renderName'},
					{name:"SiteName",text:LANG("网站名"),sort:false,align:'left',width:220,render:'renderName'},
					{name:"SiteUrl",text:LANG("网址"),sort:false,align:'left',width:220,render:'renderName'},
					{name:'verifyStatus',text:LANG("审核状态"),align:'center',width: 50,render:'renderVerifyStatus'},
					{name:"IsSlave",text:LANG("类型"),align:'center',render:'renderType'}
				]
				,'opClick':true
				,"hasTab":false
				,"hasAmount":false
				,"hasExport":false
				,'reqType': 'websocket'
				,"url":"qualification/list"
			});

			// 子表格时参数处理
			//if (config.is_sub_grid){
			//	config.is_sub_grid = false;
			//	// config.hasSearch = true;
			//	config.param = $.extend(config.param, {
			//		'CampanyId': config.sub_id
			//	});
			//}
			//this.verifyResults = [];
			this.Super('init', arguments);
			this.gridType = 'aptitudeList';
			this.$verifyLists = {};

		},
		afterBuild: function(){
			this.Super('afterBuild', arguments);
			this.uiProxy('.P-adminAptitudeBtnVerify', 'click', 'eventShowStatus');
		},
		onListOpClick: function(ev){
			if(ev.param.op === 'verifyStatus'){
				var idx = ev.param.index;
				var id = ev.param.data._id;
				var list = this.$.list;

				var subs = this.$verifyLists[idx] || null;
				if (subs){
					if (subs.id != id){
						subs.mod.destroy();
						subs = null;
					}
				}
				if (!subs){
					// 新建对象
					//var subRow = list.showSubRow(idx);
					pubjs.alert('这里要创建子表格啊~~~');
					//this.$verifyLists[idx] = {
					//	'mod': this.create(AptitudeVerify, {
					//		target: subRow.div,
					//		param:{Id:id}
					//	}),
					//	'id': id
					//};
				}else {
					list.toggleSubRow(idx);
				}
				return false;
			}
		}
		,renderType: function(i, val, row, con) {
			var append = '';
			if(row.BrandName)
			{
				append = LANG('【品牌 %1】', row.BrandName);
			}

			return (!val ? LANG('主资质') : LANG('从资质')) + append;
		}
		,renderName: function(i,val,row,con){
			var html = '<span class="M-tableListWidthLimit" title="'+val+'">'+val+'</span>';
			return $(html).width(250);
		}
		,renderVerifyStatus: function(i, val, row, con) {
			var elm = $('<a class="P-adminAptitudeBtnVerify" data-id="' + row._id + '"/>');
			elm.attr('title', LANG("点击查看"));
			return elm;
		}
		// 审核状态图标点击，通知父模块展示tooltip
		,eventShowStatus: function(evt, elm) {
			var $elm = $(elm);
			var id = $elm.attr('data-id');
			this.fire('showStatusTip', {
				id: +id,
				elm: $elm
			});
		}
	});

	exports.base = Base;

});